{extend name="public/base" /} 
{block name="style"}
	<link href="__CSS__/cash.css" rel="stylesheet">	
	<style>
		.s_active{
			background-color: #0D8DDB;
			color: #fff;
			font-size: 14px;
		}
		.m_input{
			width: 50px!important;
		    text-align: center;
		    height: 30px;
		    border: 1px solid #EEE;
		    -webkit-border-radius: 0!important;
		    -moz-border-radius: 0!important;
		    border-radius: 0!important;
		    line-height: 28px!important;
		}
		.sk_table tr td{
			border: 1px #e7eaec solid;height:40px;line-height:40px;
			text-align: center;
		}
	</style>
{/block}
{block name="body"}
<div class="gray-bg" data-scroll="y" data-scroll-destroy="true" id="container" scroll="true">
	<div id="gd_box" class="ibox-content" style="width:95%;height:60px;float: left;margin-top: 20px;margin-left: 20px;">
		<div class="  animated fadeInRight">
			<div class="input-group m-b">
                <div class="input-group-btn">
                    <button tabindex="-1" id="goods_type"  class="btn btn-white s_active" type="button">普通商品</button>
                </div>
                <div class="input-group-btn">
                    <button tabindex="-1" onclick="change_box(this,'pk_box','gd_box',1)" class="btn btn-white" type="button">商品套餐</button>
                </div>
                <input type="text" id="skey" class="form-control" onchange="goods_scan('1')" placeholder="扫描商品编号" >
            </div>
		</div>
        <div style="text-align: right;">
        </div>
    </div>
	<div id="pk_box" class="ibox-content" style="display:none;width:95%;height:60px;float: left;margin-top: 20px;margin-left: 20px;">
		<div class="  animated fadeInRight">
			<div class="input-group m-b">
                <div class="input-group-btn">
                </div>
                <div class="input-group-btn">
                    <button  tabindex="-1" onclick="change_box(this,'gd_box','pk_box',2)" class="btn btn-white " type="button">普通商品</button>
                </div>
                <div class="input-group-btn">
                    <button tabindex="-1"  class="btn btn-white s_active" type="button">套餐商品</button>
                </div>
                <input type="text" id="skeys" class="form-control" onchange="package_scan('2')" placeholder="扫描套餐编号" >
            </div>
  		</div>	        
        <div style="text-align: right;">
        </div>
   </div>
</div>
<div id="car_box" class="ibox-content" style="width:95%;height:500px;display:none;margin-top: 0px;margin-left: 20px;">
	<span class="  animated fadeInRight">
		<div class="input-group m-b" style="width:100%;text-align: center;">
           <span class="b_rs_pan" style="font-size: 24px;float: left;">金额:&nbsp;&nbsp;&nbsp;</span><span   style="float: left;color: red;">￥<span id="total_price" style="color: red;" class="b_rs_pan">0</span></span> <span class="b_rs_pan" >商品/套餐列表</span>
        </div>
	</span>
	<table class="table  table-hover tcash">
            <thead>
            <tr class="long-tr text-center">
                <th >名称</th>
                <th >单价</th>
                <th >数量</th>
                <th >小计</th>
                <th >操作</th>
            </tr>
        </thead>
    </table>
    <div style="overflow-y: scroll;height: 400px;">
    <table class="table table-hover">
        <tbody id="goods_cart" class=" text-left">
        	
        </tbody>
    </table>
    </div>
</div>

<div class="ibox-content" id="no_detail" style="width:95%;height:500px;display:inline-block;margin-top: 0px;margin-left: 20px;">
	<div class="middle-box text-center animated fadeInDown">
		<h2>出售列表是空的</h2>
		<div class="error-desc">
				<p>扫描商品条码，商品会自动添加到这里</p>
		</div>
	</div>
</div>
<div class=" gray-bg" data-scroll="y" data-scroll-destroy="true" id="container1" style="display: none;" scroll="true">
<div class="ibox float-e-margins" style="width:47%;float: left;margin-top: 20px;margin-left: 20px;">
		<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="input-group m-b">
		        <input type="text" id="key" name="key" class="form-control" placeholder="搜索会员卡号/手机号/姓名">
		        <span class="input-group-addon" > <img src="__IMG__/search.png" /></span>
		        <span class="input-group-addon" onclick="adduser()"><img src="__IMG__/adduser.png" /></span>
		    </div>
  		</div>
  		<div  id="member_info" style="display: none;" >
			<p><span class="m_rs_pan ">会员卡号:</span><span id="no"></span><span class="card_type">王者(无折扣)</span></p>
			<p><span class="m_rs_pan ">姓名:<span id="name"></span></span>
			   <span class="m_rs_pan r1">手机号:<span id="mobile"></span></span>
			   <span class="m_rs_pan r1">余额:<span id="money"></span></span>
			    <span class="m_rs_pan r1">积分:<span id="score"></span></span>
			</p>
  		</div>
 		<div class="row line" ></div>
		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		        <span class="rs_pan">账单金额<span class="m_rs_pan">(元)</span></span>
		        <input onkeyup="keyup_price(this)" readonly="readonly" type="text" id="price" class="form-control rs_input" placeholder="0.00￥"> 
		    </div>
  		</div>
  		<div class="row line" ></div>
		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		        <span class="rs_pan">折后金额<span class="m_rs_pan">(元)</span></span>
		        <input type="text" id="zhe_price" readonly="readonly" class="form-control rs_input" placeholder=""> 
		    </div>
  		</div>
  		<div class="row line" ></div>
		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		        <span class="rs_pan">赠送积分</span>
		        <input type="text" readonly="readonly" class="form-control rs_input" placeholder=""> 
		    </div>
  		</div>
  		<div class="row line" ></div>
		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		        <span class="b_rs_pan">应收金额<span class="m_rs_pan">(元)</span></span>
		        <input type="text" id="ys_money" readonly="readonly" class="form-control rs_input" placeholder=""> 
		    </div>
  		</div>
  		<div class="row line" ></div>
		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		       <button onclick="search_emp()" tabindex="-1" class="btn btn-white" type="button"><i class="fa fa-plus"></i>选择导购</button>
		       <br />
		       <div  id="emp_info"  style="display: none;">
				<p><span class="m_rs_pan ">导购员工号:<span id="zno"></span></span>
				   <span class="m_rs_pan r1">职务:<span id="zname"></span></span>
				</p>
  			   </div>
                <textarea id="ccomment" name="comment" style="height: 80px;width: 100%;" class="form-control" required="" placeholder="填写备注" aria-required="true"></textarea>
		    </div>
  		</div>
        </div>
  	</div>
	<div  style="width:570px;display:inline-block;float: left;margin-top: 40px;margin-left: 20px;background-color: #fff;">
			<div class="wrapper wrapper-content animated fadeInRight" style="padding-top: 5px;padding-left: 25px;">
		<div class="row">
			<div class="input-group m-b" style="width: 100%;margin-bottom: 3px;">
		         <div style="float:left"><span class="b_rs_pan" >支付方式?</span></div>
		        <div style="float:right;margin-right: 30px;"> 找零:<span style="float:right;margin-right: 25px;" class="rs_pan" id="zhaoling" ></span></div>
		    </div>
  		</div>
 		<div class="row line" style="padding-bottom: 3px;"></div>
		<div class="" >
			<ul class="nav pay_method">
				<li class="sku" onClick="switch_spec(this)" data = "1">
					<p><img src="__IMG__/pay.png"/></p>
					<p><span class="p_name">现金</span></p>
					<s></s>
				</li>
				<li class="sku " onClick="switch_spec(this)" data = "2">
					<p><img src="__IMG__/card.png"/></p>
					<p><span class="p_name">会员卡</span></p>
					<s></s>
				</li>
				<li class="sku" onClick="switch_spec(this)" data = "3">
					<p><img src="__IMG__/weixin.png" /></p>
					<p><span class="p_name">微信</span></p>
					<s></s>
				</li>
				<li class="sku" onClick="switch_spec(this)" data = "4">
					<p><img src="__IMG__/alipay.png"/></p>
					<p><span class="p_name">支付宝</span></p>
					<s></s>
				</li>
				<li class="sku" onClick="switch_spec(this)">
					<p><img src="__IMG__/card.png"/></p>
					<p><span class="p_name">自定义</span></p>
					<s></s>
				</li>
			</ul>
  		</div>
  		<div class="row line" style="margin-top: 5px;"></div>
  		<div class="row" style="margin-left: 10px;height:25px;line-height: 25px;">
                <div onclick="select_juan()" style="display: inline;"><i class="fa fa-plus"></i>优惠券</div>
                <div id="coupon_juan" style="display: inline-block;padding-left: 20px;"></div>
  		</div>
  		<div class="row line" ></div>
  		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		        <span class="b_rs_pan">付款金额<span class="m_rs_pan">(元)</span></span>
		        <input type="text" onkeyup="keyup_pay(this)" id="pay_money" class="form-control rs_input1 " placeholder="0.00￥"> 
		    </div>
  		</div>
  		<div class="row line" ></div>
		<div class="row" style="margin-left: 20px;">
            <button class="btn btn-primary p-btn" type="button" onclick="confirm_sk()">确定收款</button>
            <button class="btn btn-white p-btn" type="button" onclick="$('#container').show();$('#container1').hide();$('#car_box').show();">返回</button>
        </div>
		</div>
  		<input  type="hidden" name="pay_method" id="pay_method" />
  		<input type="hidden" name="dg_empno" id="dg_empno" />
  		<input type="hidden" name="line_member_id" id="line_member_id" />
	</div>
</div>
<div class="row" style="z-index:100;width:100%;margin-left: 20px;position: absolute;bottom: 30px;background-color: #CCCCCC;">
	<span><button class="btn btn-primary p-btn" type="button" onclick="guadan()">挂单</button>
	<button class="btn btn-primary p-btn" type="button" onclick="jiegua()">解挂</button>
	</span>
	<span style="margin-left:250px;">
    <button class="btn btn-primary p-btn" style="background-color: #CA4440;" type="button" onclick="sk()">收款</button>
    <button class="btn btn-white p-btn" type="button" onclick="reset_gd()">清空</button>
    </span>
</div>
{/block} {block name="script"}
<script src="__JS__/cash.js"></script>
<script>
  	var cartlist={};
  	//获取焦点
	$('#skey').focus();

  	function sk(){
		var check=check_goods();
		if(check){
			var price=$("#total_price").text();
			$("#container").hide();
			$("#container1").show();
			$("#price").val(price);
			$("#zhe_price").val(price);
			$("#ys_money").val(price);
			$("#car_box").hide();
		}
  	}
	function check_goods(){
		if($.isEmptyObject(cartlist)){
			layer.msg("您未添加任何购买商品!")
			return false;
		}
		return true;
	}
	function guadan(){
			var check=check_goods();
			if(check){
				show_gd();
			}
	}
	function goods_scan(type){	
		var dt = null;
		if(dt==null){
				var skey=$("#skey").val();
				dt={'key':skey};
			}
			$.ajax({
				url:'get_goods_lists',
				data:dt,
				type:"post",
				success: function(data) {
					var html="";
					var res=data.data;
					if(res==null){
						return;
					}
					for(var i=0;i<res.length;i++){
						var gd=res[i];  	
	                	var goods_names="";
						var arr={};
						if(type==2){
							goods_names=gd.goods_name;
							arr['goods_names']=goods_names;
						}else{
							arr['goods_names']="";
						}
						var id=gd.id;
						var name=gd.goods_name;
						var price=gd.sale_price;
						var cart=cartlist[id+type];
						console.log(id+type);
						if(cart!=null){
							cartlist[id+type]['price']=parseFloat(cartlist[id+type]['price'])+parseFloat(price);
							cartlist[id+type]['num']=cartlist[id+type]['num']+1;
						}else{
							arr['type']=type;
							arr['name']=name;
							arr['price']=price;
							arr['total_price']=price;
							arr['num']=1;
							arr['sid']=id;
							arr['is_zs']=0;//是否赠送
							cartlist[id+type]=arr;							
						}
						var has=$("#goods_"+id+type);
						if(has.val()==undefined){
							var html='<tr>'+
								 '<td style="width:260px;">'+name+'</br>'+goods_names+'</td>'+
								 '<td>'+price+'</td>'+
								 '<td><input data-name='+id+type+'  id=goods_'+id+type+'  class="m_input" type="text" value=1 /></td>'+
								 '<td id=total_'+id+type+'>'+price+'</td>'+
								 '<td data-name='+id+type+' style="font-size:16px;"><span class="zs_pan" data-name='+id+type+' >赠</span>&nbsp;&nbsp;<span class="del_pan" data-name='+id+type+' >删</span></td>'+
								 '</tr>';
							$("#goods_cart").append(html);
							setEvent();
						}else{
							has.val(parseFloat(has.val())+1);
							$("#total_"+id+type).text(parseFloat($("#total_"+id+type).text())+parseFloat(price));
						}
					 	var total_price=parseFloat($("#total_price").text())+parseFloat(price);
						$("#total_price").text(total_price);
					}
				}				
			})
			$("#skey").val('');
			if(cartlist!=null){
				$("#car_box").show();
				$("#no_detail").hide();
			}else{
				$("#no_detail").show();
				$("#car_box").hide();
			}
	}
	function package_scan(type){
		var dt = null;
		if(dt==null){
				var skey=$("#skeys").val();
				dt={'key':skey};
			}
			$.ajax({
				url:'get_package_lists',
				data:dt,
				type:"post",
				success: function(data) {
					var html="";
					var res=data.data;
					if(res==null){
						return;
					}
					for(var i=0;i<res.length;i++){
						var gd=res[i];  	
	                	var goods_names="";
						var arr={};
						if(type==2){
							goods_names=gd.package_name;
							arr['goods_names']=goods_names;
						}else{
							arr['goods_names']="";
						}
						var id=gd.id;
						var name=gd.package_name;
						var price=gd.package_price;
						var cart=cartlist[id+type];
						if(cart!=null){
							cartlist[id+type]['price']=parseFloat(cartlist[id+type]['price'])+parseFloat(price);
							cartlist[id+type]['num']=cartlist[id+type]['num']+1;
						}else{
							arr['type']=type;
							arr['name']=name;
							arr['price']=price;
							arr['total_price']=price;
							arr['num']=1;
							arr['sid']=id;
							arr['is_zs']=0;//是否赠送
							cartlist[id+type]=arr;
							console.log(id+type);
						}
						var has=$("#goods_"+id+type);
						if(has.val()==undefined){
							var html='<tr>'+
								 '<td style="width:260px;">'+name+'</br>'+goods_names+'</td>'+
								 '<td>'+price+'</td>'+
								 '<td><input data-name='+id+type+'  id=goods_'+id+type+'  class="m_input" type="text" value=1 /></td>'+
								 '<td id=total_'+id+type+'>'+price+'</td>'+
								 '<td data-name='+id+type+' style="font-size:16px;"><span class="zs_pan" data-name='+id+type+' >赠</span>&nbsp;&nbsp;<span class="del_pan" data-name='+id+type+' >删</span></td>'+
								 '</tr>';
							$("#goods_cart").append(html);
							setEvent();
						}else{
							has.val(parseFloat(has.val())+1);
							$("#total_"+id+type).text(parseFloat($("#total_"+id+type).text())+parseFloat(price));
						}
					 	var total_price=parseFloat($("#total_price").text())+parseFloat(price);
						$("#total_price").text(total_price);
					}
				}				
			})
			$("#skeys").val('');
			if(cartlist!=null){
				$("#car_box").show();
				$("#no_detail").hide();
			}else{
				$("#no_detail").show();
				$("#car_box").hide();
			}
	}
	
	function setEvent(){
  		$("#goods_cart .m_input").change(function(){
  			change_goods(this);
  		})
  		$("#goods_cart .zs_pan").unbind('click').click(function(){
  			zs_goods(this);
  		})
  		$("#goods_cart .del_pan").unbind('click').click(function(){
  			del_goods(this);
  		})
  	}
	
	/**
	 * 改变商品数量
	 */
	function change_goods(obj){
		var ckey=$(obj).data("name");
		var num=parseFloat($(obj).val());
		$total_price=num*cartlist[ckey]['price'];
		var total_price1=parseFloat($("#total_price").text());
		var is_zs=cartlist[ckey]["is_zs"];
		if(is_zs==0){
			total_price1+=parseFloat($total_price-parseFloat(cartlist[ckey]['total_price']));
			$("#total_price").text(total_price1);
		}
		cartlist[ckey]['num']=$(obj).val();
		cartlist[ckey]['total_price']=$total_price;
		$("#total_"+ckey).text($total_price);
	}
	
	/**
	 * 赠送商品
	 */
	function zs_goods(obj){
		$(obj).toggleClass("zs_active");
		var ckey=$(obj).data("name");
		$("#total_"+ckey).toggleClass("zs_total");
		console.log(cartlist[ckey]);
		var is_zs=cartlist[ckey]["is_zs"];
		var total_price=parseFloat($("#total_price").text());
		if(is_zs==1){
			cartlist[ckey]["is_zs"]=0;
			total_price+=parseFloat(cartlist[ckey]['total_price']);
			$("#total_price").text(total_price);
		}else{
			total_price-=parseFloat(cartlist[ckey]['total_price']);
			$("#total_price").text(total_price);
			cartlist[ckey]["is_zs"]=1;
		}
	}
	
	/**
	 * 删除购物车商品
	 */
	function del_goods(obj){
		var con=layer.confirm('确定删除?', function(index){
			var total_price=parseFloat($("#total_price").text());
			var ckey=$(obj).data("name");
			var is_zs=cartlist[ckey]["is_zs"];
			if(is_zs==0){
				total_price-=parseFloat(cartlist[ckey]['total_price']);
				$("#total_price").text(total_price);
			}
			delete(cartlist[ckey]);
			$(obj).parent().parent().remove();
			layer.close(con);			
		});		
	}
	function show_gd(){
		var html='<div class="form-group" id="add_form">'+
			'<div class="input-group col-sm-6">'+
			'<input type="text" id="memo"  placeholder="请输入挂单备注"  class="form-control" style="width: 300px;" />'+
			'<span class="input-group-btn"> <button type="button" onclick="confirm_gd()" class="btn btn-primary">确定</button> </span>'+
			'</div></div>';
			var index=layer.open({
			title:false,
			btn:false,
		 	area: ['400px', '100px'] ,
			content: html,
			yes: function(index, layero){
			        layer.msg("111");
			}
		});

	}
	function confirm_gd(){
				var memo=$("#memo").val();
				var total_price=parseFloat($("#total_price").text());
				var data={"memo":memo,"price":total_price,"data":cartlist}
				$.ajax({
					url:'guadan',
					data:data,
					type:"post",
					success: function(data) {
						if(data==1){
							layer.msg("挂单成功");
							reset_gd();
						}else{
							layer.msg("挂单失败");
						}
					}
				})
	}
	//清空挂单
	function reset_gd(){
		cartlist={};
		$("#total_price").text(0);
		$("#goods_cart").html("");
	}
	function jiegua(){
		if(!$.isEmptyObject(cartlist)){
			layer.msg("购物车有商品不能解挂")
			return false;
		}
		$.ajax({
			url:'get_orders',
			data:{"status":1},
			type:"post",
			success: function(data) {
				var list=data.list;
				var html='<div><table class="sk_table" style="width: 100%;">';
				if(list!=null){
					for(var i in list){
						var order=list[i];
						var item=order.items;
						var name="";
						for(var c in item){
							var o_item=item[c];
							name+=o_item['name']+"*"+o_item['num']+"&nbsp;&nbsp;";
						}
						html+='<tr ><td width="150px">'+order.add_time+'</td><td>'+name+"￥"+order.price+'备注:'+order.memo+'操作员:'+order.emp_id+'</td>'+
						'<td><button type="button" onclick="jiegua_order('+order.id+')" class="btn  btn-success">解挂</button><button type="button" onclick="del_order('+order.id+')" class="btn  btn-white">删除</button></td></tr>';
					}
				}else{
					html+='<tr ><td>没有挂单！</td>'+
						'</tr>';
					}
				html+="</table></div>";
				var index=layer.open({
				  title: '解挂',
			 	  area: ['750px', '400px'] ,
				  content: html,
				  btn: false
				});
			}
		})
	}
	function jiegua_order(id){
		$.ajax({
			url:'jiegua',
			data:{"id":id},
			type:"post",
			success: function(data) {
				var items=data.list;
				var html="";
				var arr={};
				for(var i=0;i<items.length;i++){
					var item=items[i];
					var goods_names="";
					arr['goods_names']="";
					if(item.type==2){
						goods_names=item['goods_names'];
						arr['goods_names']=goods_names;
					}
					var total_price=parseFloat(item['price'])*parseFloat(item['num']);
					arr['type']=item.type;
					arr['name']=item.name;
					arr['price']=item.price;
					arr['num']=item.num;
					arr['sid']=item.sid;
					cartlist[item.id+item.type]=arr;
					var tr='<tr>'+
					 '<td>'+item['name']+'</br>'+goods_names+'</td>'+
					 '<td>'+item['price']+'</td>'+
					 '<td><input class="m_input" type="text" value="'+item['num']+'" /></td>'+
					 '<td>'+total_price+'</td>'+
					 '<td>+   -</td>'+
					 '</tr>';
					 html+=tr;
				}
				$("#total_price").text(total_price.toFixed(2));
				$("#goods_cart").append(html);
				layer.msg("解挂成功");
			}
		})
	}
	function del_order(id){
		layer.confirm('确定删除?', {icon: 3, title:'提示'}, function(index){
		  $.ajax({
				url:'del_order',
				data:{"id":id},
				type:"post",
				success: function(data) {
					layer.msg("删除成功");
				}
			})
		 
		});
	}
	$(".dropdown-menu li").click(function(){
		var goods_typeid=$(this).attr('data-id');
		$("#goods_type").text($(this).attr('data-name'));
		get_goods_list({'goods_typeid':goods_typeid});
	})
	function select_goods(obj,type){
		var goods_names="";
		var arr={};
		if(type==2){
			goods_names=$(obj).attr("data-goods");
			arr['goods_names']=goods_names;
		}else{
			arr['goods_names']="";
		}
		var id=$(obj).attr("data-id");
		var name=$(obj).attr("data-name");
		var price=$(obj).attr("data-price");
		var cart=cartlist[id+type];
		if(cart!=null){
			cartlist[id+type]['price']=parseFloat(cartlist[id+type]['price'])+parseFloat(price);
			cartlist[id+type]['num']=cartlist[id+type]['num']+1;
		}else{
			arr['type']=type;
			arr['name']=name;
			arr['price']=price;
			arr['num']=1;
			arr['sid']=id;
			cartlist[id+type]=arr;
		}
		var html='<tr>'+
				 '<td>'+name+'</td>'+
				 '<td>'+price+'</td>'+
				 '<td><input class="m_input" type="text" value=1 /></td>'+
				 '<td>'+price+'</td>'+
				 '<td>+   -</td>'+
				 '</tr>';
	 	var total_price=parseFloat($("#total_price").text())+parseFloat(price);
		$("#total_price").text(total_price);
		$("#goods_cart").append(html);
	}
	function change_box(obj,show,hidden,type){
		$("#"+show).show();
		$("#"+hidden).hide();
		if(type == 1){
			//获取焦点
			$('#skeys').focus();
		}else{
			$('#skey').focus();			
		}
	}
	
	
	function confirm_sk(){
		var price=parseFloat($("#ys_money").val());
		if(price==""||isNaN(price)){
			layer.msg("请输入正确的账单金额!");
			return false;
		}
		var pay_method=$("#pay_method").val();
		if(pay_method==""){
			layer.msg("请选择支付方式!");
			return false;
		}
		var pay_money=parseFloat($("#pay_money").val());
		if(pay_money==""||isNaN(pay_money)){
			layer.msg("请输入正确的付款金额!");
			return false;
		}
		if(pay_money<price){
			layer.msg("付款金额小于账单金额!");
			return false;
		}
		if(pay_method==2){
			if($("#key").val()==""){
				layer.msg("请输入正确的会员卡号!");
				return false;
			}
			var yue=parseFloat($("#money").text());
			if(yue<parseFloat(price)){
				layer.msg("余额不足!");
				return false;
			}
		}
		var coupon_id=$("#counpon_span").attr('data-id');
		if(coupon_id==undefined){
			coupon_id=0;			
		}
		var zhaoling=parseFloat($("#zhaoling").text());
		var html='<div class="row" >'+
						'<div style="float: left;width:50%;text-align: center;">'+
							'<span id="sp_price" style="font-size:26px;font-weight:600;color:#35b12c">'+price+'</span>'+
							'<p>应收金额</p>'+
						'</div>'+
						'<div style="float: left;width:50%;text-align: center;">'+
							'<span id="sp_zhaoling" style="font-size:26px;font-weight:600;color:red">'+zhaoling+'</span>'+
							'<p>找零</p>'+
						'</div>'+
				   '</div>'+
				   '<div class="row" >'+
						'<div style="float: left;width:50%;text-align: center;">'+
							'<span>门店</span>&nbsp<label>{$store_name}</label>'+
						'</div>'+
						'<div style="float: left;width:50%;text-align: center;">'+
							'<span>收银员</span>&nbsp<label>{$mobile}</label>'+
						'</div>'+
				   '</div>';
		var index=layer.open({
		  title: '确认收款',
		  zIndex :"add_zhiwei",
	 	  area: ['500px', '250px'] ,
		  content: html,
		  btn: ['确定','取消'],
		  yes: function(index, layero){
		    //按钮【按钮一】的回调
		    	$.ajax({
					url:'shoukuan',
					data:{coupon_id:coupon_id,type:3,data:cartlist,price:price,pay_money:pay_money,zhaoling:zhaoling,pay_method:pay_method,dg_id:$("#dg_empno").val(),line_member_id:$("#line_member_id").val()},
					type:"post",
					success: function(data) {
						layer.close(index);
						callback(data);
						empty();
					}
				})
		  },btn2:function(index,layero){
		  	layer.close(index);
		  }
		});

	}
	
	
	
	function callback(data){
		if(data.code==200){
			var info=data.data;
			 var html='<div>'+
					'<div style="text-align: center;">'+
					'<i class="fa fa-check" style="color: #35b12c;font-size: 60px;font-weight: 600;"></i>'+
					'<p><span class="b_rs_pan">收款成功</span> </p>'+
					'</div>'+
				'<div class="form-group" style="padding-left: 100px;"><label class="col-sm-5 control-label">单号：</label><div class="input-group col-sm-7">'+info.sn+'</div></div>'+
					'<div class="form-group" style="padding-left: 100px;"><label class="col-sm-5 control-label">交易时间：</label><div class="input-group col-sm-7">'+info.add_time+'</div></div>'+
					'<div class="form-group" style="padding-left: 100px;"><label class="col-sm-5 control-label">门店：</label><div class="input-group col-sm-7">'+info.store_name+'</div></div>'+
					'<div class="form-group" style="padding-left: 100px;"><label class="col-sm-5 control-label">操作员：</label><div class="input-group col-sm-7">'+info.skr+'</div></div>'+
				 '</div>';
				  var index=layer.open({
				  title: '收款成功',
			 	  area: ['600px', '350px'] ,
				  content: html,
				  btn: ['我知道了','打印小票']
				  ,yes: function(index, layero){
				    layer.close(index);
				    $("#container").show();
				    $("#container1").hide();
				    $("#car_box").show();
			    	reset_gd();
			    	empty();
				  },btn2:function(index,layero){
				  	layer.msg("打印成功");
				  	$("#container").show();
				    $("#container1").hide();
				    $("#car_box").show();
			    	reset_gd();
			    	empty();
				  }
			});
			
		}else{
			layer.msg(data.msg);
			window.reload();
		}
		
	}
	function search_emp(){
		var html='<div class="form-group" id="add_form">'+
		'<label class="col-sm-3 control-label" style="width:120px">导购员工号：</label>'+
		'<div class="input-group col-sm-6">'+
			'<input type="text" id="dg_no" value="" class="form-control" />'+
		'<span id="error_tips" style="color: red;display: none;">请输入导购员工号</span></div></div>';
		var index=layer.open({
			  title: '选择导购员',
			  zIndex :"add_zhiwei",
		 	  area: ['600px', '180px'] ,
			  content: html,
			  btn: ['确定'],
			  yes: function(index, layero){
			    var dg_no=$("#dg_no").val();
			    if(dg_no==""){
			    	$("#error_tips").show();
			    	return false;
			    }else{
			    	$.ajax({
					url:'get_emp',
					data:{no:dg_no},
					type:"post",
					success: function(data) {
						if(data=="null"){
							$("#error_tips").text("该工号不存在");
							$("#error_tips").show();
						}else{
							$("#zno").text(JSON.parse(data).no);
							$("#zname").text(JSON.parse(data).zname);
							$("#dg_empno").val(JSON.parse(data).id);
							$("#emp_info").show();
							layer.close(index);
						}
					}
				})
			    }
			  }
			  });
	}
	function call_back(msg){
		layer.msg(msg);
		layer.closeAll('iframe');
	}
	function adduser(){
		layer.open({
		  type: 2, 
		  id:"add_member",
		 area: ['1050px', '550px'] ,
		 scrollbar: false,
		  content: '/web/cashier/add_member' //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
		}); 
	}
  	function switch_spec(spec)
    {
    	$("#pay_method").val($(spec).attr("data"));
//      $(spec).siblings('input').trigger('click');	 // 让隐藏的 单选按钮选中
        $(spec).parent().parent().find(".sku").removeClass('sku-bo-blo'); //   清空勾选图标
         $(spec).parent().parent().find(".sku").find("s").css("display","none");
        $(spec).addClass('sku-bo-blo'); // 当前 加上勾选图标
      	$(spec).find("s").css('display',"block"); //   
    }
	//顶部导航
	//ajax表单提交
	$("#myForm").submit(function() {
		ajaxForm();
		return false;
	});
</script>
{/block}